<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	template="../template.xhtml">

	<ui:define name="head"></ui:define>
	<ui:define name="right">

		<div class="section">
			<div class="section-title">#{msgs.mensagens}</div>
			<div class="section-content">
				<p:growl id="messages" showDetail="false" />
			</div>
		</div>
	</ui:define>
	<ui:define name="content">
		<div class="section">
			<div class="section-title">#{msgs.responsavel}</div>

			<div class="section-content">

				<h:form id="acForm" prependId="false">
					<h:outputLabel styleClass="bold" value="#{msgs.selecione_pessoa_pelo_cpf}: " />

					<p:autoComplete value="#{solicitacaoMB.view.pessoaOriginal}"
						completeMethod="#{solicitacaoMB.filtrarPessoaCPF}" var="pessoa"
						minQueryLength="3" itemLabel="#{pessoa.cpf}" itemValue="#{pessoa}"
						converter="pessoaFisicaConverter" forceSelection="true" />

					<p:commandButton value="#{msgs.btn_selecionar}" update="pessoaForm messages"
						actionListener="#{solicitacaoMB.selecionarPessoa}" />

				</h:form>

				<div class="content-separator"></div>
				<h:form id="pessoaForm" prependId="false">
					<f:validateBean disabled="true">

						<p:panel id="panel1" header="#{msgs.dados_pessoais}"
							style="margin-bottom:10px;">
							<p:messages />
							<h:panelGrid columns="3">
								<h:outputLabel styleClass="bold" for="nome" value="#{msgs.form_nome}: *" />
								<p:inputText id="nome"
									value="#{solicitacaoMB.view.pessoaAlterada.nome}"
									required="true" label="nome">
									<f:validateLength minimum="3" />
								</p:inputText>
								<p:message for="nome" />
								<h:outputLabel styleClass="bold" for="dataNascimento"
									value="#{msgs.form_data_nascimento}: *" />
								<p:calendar id="dataNascimento"
									value="#{solicitacaoMB.view.pessoaAlterada.dataNascimento}"
									showOn="button" pattern="dd/MM/yyyy" />
								<p:message for="dataNascimento" />
								<h:outputLabel styleClass="bold" for="sexo" value="#{msgs.form_sexo} *" />
								<p:selectOneMenu id="sexo"
									value="#{solicitacaoMB.view.pessoaAlterada.sexo}" var="sexo"
									converter="tcConverter" required="true">
									<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
									<f:selectItems value="#{solicitacaoMB.view.tipoSexos}"
										itemValue="#{s}" itemLabel="#{s.descricao}" var="s" />
									<p:column>#{sexo.descricao}</p:column>
								</p:selectOneMenu>
								<p:message for="sexo" />
								<h:outputLabel styleClass="bold" for="cpf" value="#{msgs.form_cpf}: *" />
								<p:inputText id="cpf"
									value="#{solicitacaoMB.view.pessoaAlterada.cpf}"
									required="true" label="cpf" />
								<p:message for="cpf" />
								<h:outputLabel styleClass="bold" for="rg" value="#{msgs.form_rg}: *" />
								<p:inputText id="rg" value="#{solicitacaoMB.view.rg.numero}"
									required="true" label="rg" />
								<p:message for="rg" />
								<h:outputLabel styleClass="bold" for="rgComp"
									value="#{msgs.form_orgao_expedidor}: *" />
								<p:inputText id="rgComp"
									value="#{solicitacaoMB.view.rg.complemento}" required="true"
									label="rgComp" />
								<p:message for="rgComp" />
								<h:outputLabel styleClass="bold" for="tituloEleitor"
									value="#{msgs.form_titulo_eleitor}: *" />
								<p:inputText id="tituloEleitor"
									value="#{solicitacaoMB.view.tituloEleitor.numero}"
									required="true" label="tituloEleitor" />
								<p:message for="tituloEleitor" />
								<h:outputLabel styleClass="bold" for="tel" value="#{msgs.form_telefone}: *" />
								<p:inputText id="tel"
									value="#{solicitacaoMB.view.telefone.numero}" required="true"
									label="tel" />
								<p:message for="tel" />
								<h:outputLabel styleClass="bold" for="cel" value="#{msgs.form_celular}: *" />
								<p:inputText id="cel"
									value="#{solicitacaoMB.view.celular.numero}" required="true"
									label="cel" />
								<p:message for="cel" />
								<h:outputLabel styleClass="bold" for="email" value="#{msgs.form_email}: *" />
								<p:inputText id="email"
									value="#{solicitacaoMB.view.email.descricao}" required="true"
									label="email" />
								<p:message for="email" />


							</h:panelGrid>
						</p:panel>
						<p:panel id="panel2" header="#{msgs.endereco_residencial}"
							style="margin-bottom:10px;">
							<h:panelGrid columns="3">
								<h:outputLabel styleClass="bold" for="logradouro"
									value="#{msgs.form_logradouro}: *" />
								<p:inputText id="logradouro"
									value="#{solicitacaoMB.view.endereco.logradouro}"
									required="true" label="logradouro" />
								<p:message for="logradouro" />
								<h:outputLabel styleClass="bold" for="numero" value="#{msgs.form_numero}: *" />
								<p:inputText id="numero"
									value="#{solicitacaoMB.view.endereco.numero}" required="true"
									label="numero" />
								<p:message for="numero" />
								<h:outputLabel styleClass="bold" for="complemento"
									value="#{msgs.form_complemento}:" />
								<p:inputText id="complemento"
									value="#{solicitacaoMB.view.endereco.complemento}"
									label="complemento" required="false" />
								<p:message for="complemento" />
								<h:outputLabel styleClass="bold" for="bairro" value="#{msgs.form_bairro}: *" />
								<p:inputText id="bairro"
									value="#{solicitacaoMB.view.endereco.bairro}" required="true"
									label="bairro" />
								<p:message for="bairro" />
								<h:outputLabel styleClass="bold" for="cep" value="#{msgs.form_cep}: *" />
								<p:inputText id="cep" value="#{solicitacaoMB.view.endereco.cep}"
									required="true" label="cep" />
								<p:message for="cep" />
								<h:outputLabel styleClass="bold" for="uf" value="#{msgs.form_estado}: *" />
								<p:selectOneMenu id="uf"
									value="#{solicitacaoMB.view.endereco.uf}" var="uf"
									converter="ufConverter" required="true">
									<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
									<f:selectItems value="#{solicitacaoMB.view.ufs}"
										itemValue="#{u}" itemLabel="#{u.descricao}" var="u" />
									<p:column>#{uf.descricao}</p:column>
									<p:ajax update="municipio"
										listener="#{solicitacaoMB.filtrarMunicipio}" />
								</p:selectOneMenu>
								<p:message for="uf" />
								<h:outputLabel styleClass="bold" for="municipio"
									value="#{msgs.form_municipio}: *" />
								<p:selectOneMenu id="municipio"
									value="#{solicitacaoMB.view.endereco.municipio}"
									converter="municipioConverter" var="municipio" required="true">
									<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
									<f:selectItems value="#{solicitacaoMB.view.municipios}"
										itemValue="#{m}" itemLabel="#{m.descricao}" var="m" />
									<p:column>#{municipio.descricao}</p:column>
								</p:selectOneMenu>
								<p:message for="municipio" />
							</h:panelGrid>
						</p:panel>

						<p:panel id="panel3" header="#{msgs.responsabilidades}"
							style="margin-bottom:10px;">
							<p:commandButton value="#{msgs.adicionar_responsabilidade}"
								actionListener="#{solicitacaoMB.mudarMostarPanelResp}"
								update="panel3" process="@this"
								rendered="#{!solicitacaoMB.view.mostarPanelResp}" />
							<h:panelGroup layout="block" id="panelResp"
								rendered="#{solicitacaoMB.view.mostarPanelResp}">
								<h:panelGrid columns="3">

									<h:outputLabel styleClass="bold" for="ua"
										value="#{msgs.form_unidade_adiministrativa}: *" />
									<p:selectOneMenu id="ua" value="#{solicitacaoMB.view.ua}"
										var="ua" converter="uaConverter" required="true">
										<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
										<f:selectItems value="#{solicitacaoMB.view.uas}"
											itemValue="#{u}" itemLabel="#{u.nome}" var="u" />
										<p:column>#{ua.nome}</p:column>
										<p:ajax update="ug" listener="#{solicitacaoMB.filtrarUG}" />
									</p:selectOneMenu>
									<p:message for="ua" />
									<h:outputLabel styleClass="bold" for="ug"
										value="#{msgs.form_unidade_gestora}: *" />
									<p:selectOneMenu id="ug"
										value="#{solicitacaoMB.view.responsavel.unidadeGestora}"
										var="ug" converter="ugConverter" required="true">
										<f:selectItem itemLabel="#{msgs.form_selecione}" itemValue="" />
										<f:selectItems value="#{solicitacaoMB.view.ugs}"
											itemValue="#{u}" itemLabel="#{u.nome}" var="u" />
										<p:column>#{ug.nome}</p:column>
									</p:selectOneMenu>
									<p:message for="ug" />
									<h:outputLabel styleClass="bold" for="tc"
										value="#{msgs.form_tipo}: *" />
									<p:selectOneMenu id="tc"
										value="#{solicitacaoMB.view.responsavel.tipo}" var="tc"
										converter="tcConverter" required="true">
										<f:selectItem itemLabel="#{msgs.form_selecione}"
											itemValue="" />
										<f:selectItems value="#{solicitacaoMB.view.tipoResponvels}"
											itemValue="#{t}" itemLabel="#{t.descricao}" var="t" />
										<p:column>#{tc.descricao}</p:column>
									</p:selectOneMenu>
									<p:message for="tc" />
									<h:outputLabel styleClass="bold" for="dataInicioExercicio"
										value="#{msgs.data_inicio_exercicio}: *" />
									<p:calendar id="dataInicioExercicio"
										value="#{solicitacaoMB.view.responsavel.dataInicioExercicio}"
										showOn="button" pattern="dd/MM/yyyy" required="true" />
									<p:message for="dataInicioExercicio" />
									<h:outputLabel styleClass="bold" for="dataFimExercicio"
										value="#{msgs.data_fim_exercicio}: *" />
									<p:calendar id="dataFimExercicio"
										value="#{solicitacaoMB.view.responsavel.dataFimExercicio}"
										showOn="button" pattern="dd/MM/yyyy" required="true" />
									<p:message for="dataFimExercicio" />

								</h:panelGrid>

								<p:commandButton value="#{msgs.btn_adicionar}"
									actionListener="#{solicitacaoMB.addResponsavel}"
									update="panel3" process="panel3" style="margin:10px 0" />
								<p:commandButton value="#{msgs.btn_cancelar}"
									actionListener="#{solicitacaoMB.mudarMostarPanelResp}"
									update="panel3" process="@this" />
							</h:panelGroup>


							<p:dataTable
								value="#{solicitacaoMB.view.pessoaAlterada.responsavels}"
								var="resp">

								<p:column>
									<f:facet name="header">
										<h:outputText value="#{msgs.coluna_unidade_administrativa}" />
									</f:facet>
									<h:outputText
										value="#{resp.unidadeGestora.unidadeAdministrativa.nome}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="#{msgs.coluna_unidade_gestora}" />
									</f:facet>
									<h:outputText value="#{resp.unidadeGestora.nome}" />
								</p:column>
								<p:column>
									<f:facet name="header">
										<h:outputText value="#{msgs.responsavel}" />
									</f:facet>
									<h:outputText value="#{resp.tipo.descricao}" />
								</p:column>
								<p:column>
									<f:facet name="header">
										<h:outputText value="#{msgs.coluna_data_inicio}" />
									</f:facet>
									<h:outputText value="#{resp.dataInicioExercicio}">
										<f:convertDateTime pattern="dd/MM/yyyy" />
									</h:outputText>
								</p:column>
								<p:column>
									<f:facet name="header">
										<h:outputText value="#{msgs.data_fim_exercicio}" />
									</f:facet>
									<h:outputText value="#{resp.dataFimExercicio}">
										<f:convertDateTime pattern="dd/MM/yyyy" />
									</h:outputText>
								</p:column>
							</p:dataTable>
						</p:panel>


						<p:commandButton value="#{msgs.btn_finalizar}" update="pessoaForm"
							actionListener="#{solicitacaoMB.finalizar}"
							process="panel1 panel2" action="solicitacao_detalhe.jsf"
							ajax="false" />

					</f:validateBean>
				</h:form>

				<div class="content-separator"></div>



				<div class="clearer"></div>

			</div>


		</div>


	</ui:define>

</ui:composition>